package org.starlight.user.controller;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.enums.ParameterIn;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.*;
import org.starlight.user.entity.Users;
import org.starlight.user.serivce.UserService;

/**
 * 用户服务
 *
 * @author huangyong
 */
@Tag(name = "用户服务", description = "用户服务")
@Slf4j
@RestController
@RequiredArgsConstructor
@RequestMapping("/user")
public class UsersController {
    private final UserService userService;


    @Operation(summary = "保存一个用户")
    @ResponseStatus(HttpStatus.OK)
    @PostMapping
    public void saveUser(@RequestBody Users users) {
        userService.saveUser(users);
    }


    @Parameter(name = "id", in = ParameterIn.PATH, required = true)
    @Operation(summary = "删除一个用户")
    @ResponseStatus(HttpStatus.OK)
    @GetMapping("/{id}")
    public void deleteUser(@PathVariable Integer id) {
        userService.deleteUser(id);
    }


}
